#include "EffectTemplatePCH.h"
#include "Pass.h"

Pass Pass::InvalidPass( NULL, NULL );

Pass::Pass( CGcontext context, CGpass pass )
: m_cgContext( context )
, m_cgPass( pass )
, m_bIsValid( false )
{
    if ( m_cgPass != NULL )
    {
        m_bIsValid = true;
        const char* passName = cgGetPassName(m_cgPass);
        if ( passName != NULL )
        {
            m_PassName = passName;
        }
    }
}

Pass::~Pass()
{}

const std::string& Pass::GetPassName() const
{
    return m_PassName;
}

bool Pass::BeginPass()
{
    if ( m_bIsValid )
    {
        cgSetPassState( m_cgPass );
    }
    return m_bIsValid;
}

void Pass::EndPass()
{
    if ( m_bIsValid )
    {
        cgResetPassState( m_cgPass );
    }
}

bool Pass::IsValid() const
{
    return m_bIsValid;
}

